package action.fkgl;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import com.util.Component;
import com.PublicSystem;
import com.util.Util;
import com.syslog.SysLogServices;
import services.fkgl.GrdjServices;
/**
 * 个人发卡管理
 * @author duy
 *
 */
@Controller
@RequestMapping("GRfk.do")
public class GrdjAction {
	GrdjServices ss = new GrdjServices();
	PublicSystem sys = PublicSystem.getInstance();
	SysLogServices log = SysLogServices.getInstance();	
	/**
	 * 性别下拉框选项
	 * @param request
	 * @param response
	 * @throws Exception
	 */
	@RequestMapping(params = "method=getaac004")
	public void getSelectaac004(HttpServletRequest request, HttpServletResponse response) throws Exception {
		List data = ss.getSelect(Component.getQuest("lx", request));
		Component.print(Util.Encode(data), response);
	}		
	/**
	 * 个人信息查询
	 * @param request
	 * @param response
	 * @throws Exception
	 */
	@RequestMapping(params = "method=getgrunitdata")
	public void getgrunitdata(HttpServletRequest request, HttpServletResponse response) throws Exception {
		HashMap user = ss.getgrUnitData(Component.getQuest("id", request));
		Component.print(Util.Encode(user), response);
		String aac001 = Component.getQuest("id", request);
		String userid = Component.getSession("userid", request);
	    String rwid = Component.getSession("rwid", request);
   		HashMap obj = new HashMap();
   		obj.put("domainid", "SBK");   //分系统号，见sys_log_bm
   		obj.put("log_type", "T05");   //日志类别，见sys_log_bm
   		obj.put("userid", userid);    //操作人
  		obj.put("rwh", rwid);	      //任务号（菜单号），取Component.getSession("rwid", request),若特殊则为空为自定义
   		obj.put("content", "用户" + userid + "查询" + "社会保障卡号为" + aac001 + "的客户信息");  //日志内容，自己组合拼装
   		obj.put("czqd", "Q2");	      //操作渠道，见sys_log_bm
   		obj.put("czrlb", "L01");      //操作人类别，见sys_log_bm
   		obj.put("datain", userid);    //输入参数
   		obj.put("dataout", Util.Encode(user));//输出参数
  		log.sysLogMap(obj, request);	    		
	}		
	/**
	 * 个人发卡登记信息
	 * @param request
	 * @param response
	 * @throws Exception
	 */
	@RequestMapping(params ="method=savegrunit")
	public void savegrunit(HttpServletRequest request, HttpServletResponse response) throws Exception {
		String idreturn = "";
		String json=request.getParameter("data");
		ArrayList rows = (ArrayList)Util.Decode(json);		
		HashMap row = (HashMap)rows.get(0);	
		String aac001 = (String) row.get("aac001");
		String aae011 = Component.getSession("userid", request);	   	
		row.put("aae011", aae011);			
		idreturn = ss.insertUnit(row);		
	    Component.print(idreturn, response);	    
        String userid = Component.getSession("userid", request);
        String rwid = Component.getSession("rwid", request);
   		HashMap obj = new HashMap();
   		obj.put("domainid", "SBK");   //分系统号，见sys_log_bm
   		obj.put("log_type", "T02");   //日志类别，见sys_log_bm
   		obj.put("userid", userid);    //操作人
  		obj.put("rwh", rwid);	      //任务号（菜单号），取Component.getSession("rwid", request),若特殊则为空为自定义
   		obj.put("content", "用户" + userid  +"执行" + "社会保障卡号为" + aac001 + "的发卡信息");  //日志内容，自己组合拼装
   		obj.put("czqd", "Q2");	      //操作渠道，见sys_log_bm
   		obj.put("czrlb", "L01");      //操作人类别，见sys_log_bm
   		obj.put("datain", userid);    //输入参数
   		obj.put("dataout", idreturn);//输出参数
  		log.sysLogMap(obj, request);	    
	} 
}
